<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<script type="text/javascript" src="../js/jquery-1.8.3.js"></script>
		<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../js/easyui/locale/easyui-lang-zh_CN.js"></script>
		<link rel="stylesheet" type="text/css" href="../js/easyui/themes/default/easyui.css" />
		<link rel="stylesheet" type="text/css" href="../js/easyui/themes/icon.css" />
		<script type="text/javascript" src="../js/ztree/jquery.ztree.all-3.5.js"></script><br />
		<link rel="stylesheet" href="../js/ztree/zTreeStyle.css" />
		<title>xiaowang</title>
		<script type="text/javascript">
			$(function() {
				/*$("#myclick").click(function(){
					$("#mytab").tabs('add',{
					title:'传智播客',
					content:'煞笔王松',
					closable:true
					});
				});*/
				var setting = {
					data: {
						simpleData: {
							enable: true
						}
					},
					callback: {
						onClick: function(event, treeId, treeNode) {
							var content = '<div style="width:100%;height:100%;overflow:hidden;">' +
								'<iframe src="' +
								treeNode.page +
								'" scrolling="auto" style="width:100%;height:100%;border:0;"></iframe></div>';
							if(treeNode.page != undefined && treeNode.page != "") {
								//								alert(treeNode.page);
								if($("#mytab").tabs('exists', treeNode.name)) {
									("#mytab").tabs('select', treeNode.name)
								} else {
									//									alert("11");
									$("#mytab").tabs('add', {
										title: treeNode.name,
										content: content,
										closable: true
									});
								}
							}
						}
					}
				}
				var nodes = [
					{ "id": 1, "pId": 0, "name": "父节点" },
					{ "id": 11, "pId": 1, "name": "子节点1", page: "http://www.baidu.com" },
					{ "id": 12, "pId": 1, "name": "子节点2", page: "http://www.baidu.com" }
				]
				$.fn.zTree.init($("#baseMenu"), setting, nodes);

				var name;
				$("#mytab").tabs({
					onContextMenu: function(e, title, index) {
						//						alert(title);
						name = title;
						e.preventDefault();
						$('#mm').menu('show', {

							left: e.clientX,

							top: e.clientY

						});

					}
				});
				$('#mm').menu({

					onClick: function(item) {
						//alert(item.name);
						if(item.name == 'closeNow') {
							$("#mytab").tabs('close', name);
						} else if(item.name == 'closeOthers') {
							var allTabs = $("#mytab").tabs('tabs');
							$(allTabs).each(function(i, n) {
								//								alert(n.panel('options').title);
								if(n.panel('options').title != name) {
									$("#mytab").tabs('close', n.panel('options').title);
								}
							});
						} else if(item.name == 'closeAll') {
							var allTabs = $("#mytab").tabs('tabs');
							$(allTabs).each(function(i, n) {
								$("#mytab").tabs('close', n.panel('options').title);
							});
						}
					}

				});

				/*		$.messager.show({
							 title:'降价促销',
							 msg:"减价大促销,<a href='#'>click here</a>",
							 timeout:0
						});*/
				/*$.messager.progress({
					interval:500
				})
				window.setTimeout("$.messager.progress('close')",5500);*/
				
			});
		</script>
	</head>

	<body class="easyui-layout">
		<div data-options="region:'north',title:'North Title'" style="height: 160px;"></div>
		<div data-options="region:'south',title:'South Title'" style="height: 160px;"></div>
		<div data-options="region:'west',title:'West Title'" style="width: 160px;">
			<div class="easyui-accordion" data-options="fit:true">
				<div data-options="title:'基础菜单'">
					<ul id="baseMenu" class="ztree"></ul>
				</div>
				<div data-options="title:'基础菜单'"></div>
			</div>
		</div>
		<div data-options="region:'east',title:'East Title'" style="width: 160px;">
			<a href="javascript:void(0)" id="mb" class="easyui-menubutton" data-options="menu:'#window',iconCls:'icon-edit'">Edit</a>

			<div id="window" style="width:150px;">

				<div data-options="iconCls:'icon-undo'">Undo</div>

				<div data-options="iconCls:'icon-redo'">Redo</div>

				<div class="menu-sep"></div>

				<div>Cut</div>

				<div>Copy</div>

				<div>Paste</div>

				<div class="menu-sep"></div>

				<div data-options="iconCls:'icon-remove'">Delete</div>

				<div>Select All</div>

			</div>

		</div>
		<div data-options="region:'center',title:'Center Title'">
			<div class="easyui-tabs" data-options="fit:true" id="mytab">
				<div data-options="title:'选项卡一',closable:true"></div>
				<div data-options="title:'选项卡二',closable:true"></div>
			</div>
		</div>
		<div id="mm" class="easyui-menu" style="width:120px;">

			<div data-options="name:'closeNow'">关闭当前窗口</div>

			<div data-options="name:'closeOthers'">关闭其他窗口</div>
			<div class="menu-sep"></div>
			<div data-options="iconCls:'icon-cancel',name:'closeAll'">关闭所有窗口</div>

		</div>

	</body>

</html>